import {getAction} from '@/api/manage'

//模糊搜索-人
export const querySearchAsync_empid = (queryString, callback, menuPath='') => {
    var list = []
    var pagePqrams = {
        current:1,
        size:100
    }
    var queryPqrams = {}
    let fuzzySearchType = ''
    //debugger
    console.log(menuPath,'menuPath22')
    
    if(queryString == '') return false
    
    
    //[SMD|SVR|SDT|ST1|STC] 开头的，会认为是工号查询
    if(/^[s|S]+[m|M|v|V|d|D|t|T]+[d|D|r|R|t|T|1|c|C]/.test(queryString)){
        queryPqrams.account = queryString
    }else{
        queryPqrams.realName = queryString
    }
    
    getAction('/api/blade-system/user-admin/search',Object.assign({},pagePqrams,queryPqrams)).then(res=>{
           let data = res.data.data.records
           resultOp(data)
    })
    // searchUserList(1,100,{realName:queryString}).then(res => {
    //     let data = res.data.data.records
    //     resultOp(data)
    // })
    
    callback&&typeof callback=='function'&&callback(list)

    function resultOp(data){
        data.forEach(ele => {
            let showValue
            let showType = 'onlyName';
            if(showType === 'onlyName') {
                let showName = ele.real_name?ele.real_name:ele.realName
                showValue = showName+ele.account
            }
            let listItem = {
              "value":showValue,
              "account":ele.account,
              "realName":ele.realName,
              "userName":ele.realName,
              "userId":ele.account,
            }
            list.push(listItem)
        })
    } 
  }


  